﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CardGame
{
    public class cl_0423_PrimaryState : cl_0423_AbstractState
    {
        public cl_0423_PrimaryState(cl_0423_AbstractState state)
        {
            Console.WriteLine("构造函数");
            this.acc = state.acc;
            this.stateName = "新手";
        }

        public cl_0423_PrimaryState(cl_0423_GameAccount acc)
        {
            this.point = 0;
            this.acc = acc;
            this.stateName = "新手";
        }

        public override void play(string outcome)
        {
            if (outcome == "win")
            {

                this.point+= acc.score;
                Console.WriteLine(acc.getName()+"游戏胜利,增加"+acc.score+"分");
                checkState();
                Console.WriteLine("剩余积分:"+this.point+"当前级别:"+acc.getState().getStateName());
            }
            else
            {
                Console.WriteLine(acc.getName() + "游戏失败,减少" + "10" + "分");
                this.point -= 10;
                checkState();
                Console.WriteLine("剩余积分:" + this.point + "当前级别:" + acc.getState().getStateName());
            }
        }

        public void checkState()
        {
            if (point > 500)
            {
                acc.setState(new cl_0423_FinalState(this));
            }else if (point > 300)
            {
                acc.setState(new cl_0423_ProfessionalState(this));
            }else if (point > 100)
            {
                acc.setState(new cl_0423_SecondaryState(this));
            }
        }
    }
}